diff -P -r -u -b -d postgresql-7.1.3/configure pgsql713my/configure --- postgresql-7.1.3/configure Thu Aug 16 21:36:31 2001 +++ pgsql713my/configure Sat Nov 24 23:20:30 2001 @@ -696,6 +696,7 @@ openbsd*) template=openbsd ;; osf*) template=osf ;; qnx*) template=qnx4 ;; + nto-qnx*) template=nto-qnx ;; sco*) template=sco ;; solaris*) template=solaris ;; sunos*) template=sunos4 ;; @@ -1107,6 +1108,10 @@ # On AIX, default compiler to xlc. if test "$template" = aix && test -z "$CC" ; then CC=xlc; fi +# On QNX6, default compiler to qcc. +if test "$template" = nto-qnx && test -z "$CC" ; then CC=qcc; fi + + # Save CFLAGS from the environment has_environ_CFLAGS="${CFLAGS+yes}" save_CFLAGS=$CFLAGS @@ -2609,7 +2614,6 @@ else echo "$ac_t""no" 1>&6 fi - CPPFLAGS="$CPPFLAGS $INCLUDES" diff -P -r -u -b -d postgresql-7.1.3/contrib/pgbench/pgbench.c pgsql713my/contrib/pgbench/pgbench.c --- postgresql-7.1.3/contrib/pgbench/pgbench.c Sat Feb 10 04:31:25 2001 +++ pgsql713my/contrib/pgbench/pgbench.c Thu Nov 29 23:39:55 2001 @@ -718,7 +718,7 @@ /* set random seed */ gettimeofday(&tv1, 0); - srand((uint) tv1.tv_usec); + srand((unsigned int) tv1.tv_usec); /* get start up time */ gettimeofday(&tv1, 0); diff -P -r -u -b -d postgresql-7.1.3/src/Makefile.global.in pgsql713my/src/Makefile.global.in --- postgresql-7.1.3/src/Makefile.global.in Sat Mar 10 12:38:59 2001 +++ pgsql713my/src/Makefile.global.in Sat Nov 24 23:45:18 2001 @@ -168,6 +168,9 @@ ld_R_works = @ld_R_works@ LDFLAGS = @LDFLAGS@ LDREL = -r +ifeq (@PORTNAME@, nto-qnx) +LDREL += -E +endif LDOUT = -o RANLIB = @RANLIB@ LORDER = @LORDER@ diff -P -r -u -b -d postgresql-7.1.3/src/Makefile.shlib pgsql713my/src/Makefile.shlib --- postgresql-7.1.3/src/Makefile.shlib Sun Apr 15 06:25:07 2001 +++ pgsql713my/src/Makefile.shlib Sat Nov 24 22:46:29 2001 @@ -173,6 +173,12 @@ LINK.shared = $(COMPILER) -shared -Wl,-soname,$(soname) endif +ifeq ($(PORTNAME), nto-qnx) + shlib := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION) + LINK.shared = $(COMPILER) -shared -Wl,-soname,$(soname) +endif + + ifeq ($(PORTNAME), solaris) shlib := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION) LINK.shared = $(COMPILER) -G diff -P -r -u -b -d postgresql-7.1.3/src/backend/libpq/hba.c pgsql713my/src/backend/libpq/hba.c --- postgresql-7.1.3/src/backend/libpq/hba.c Sat Feb 10 04:31:26 2001 +++ pgsql713my/src/backend/libpq/hba.c Wed Dec 12 14:32:23 2001 @@ -528,12 +528,17 @@ } } - - +#if defined(__QNXNTO__) // Andy Latin +static void +ident(const struct in_addr remote_ip_addr, const struct in_addr local_ip_addr, + const int remote_port, const int local_port, + bool *ident_failed, char *ident_username) +#else static void ident(const struct in_addr remote_ip_addr, const struct in_addr local_ip_addr, const ushort remote_port, const ushort local_port, bool *ident_failed, char *ident_username) +#endif { /*-------------------------------------------------------------------------- Talk to the ident server on host "remote_ip_addr" and find out who diff -P -r -u -b -d postgresql-7.1.3/src/backend/libpq/pqsignal.c pgsql713my/src/backend/libpq/pqsignal.c --- postgresql-7.1.3/src/backend/libpq/pqsignal.c Thu Mar 22 05:59:30 2001 +++ pgsql713my/src/backend/libpq/pqsignal.c Wed Dec 12 18:42:40 2001 @@ -117,8 +117,10 @@ act.sa_handler = func; sigemptyset(&act.sa_mask); act.sa_flags = 0; +#if !defined(__QNXNTO__) // Andy Latin if (signo != SIGALRM) act.sa_flags |= SA_RESTART; +#endif if (sigaction(signo, &act, &oact) < 0) return SIG_ERR; return oact.sa_handler; diff -P -r -u -b -d postgresql-7.1.3/src/backend/port/Makefile.in pgsql713my/src/backend/port/Makefile.in --- postgresql-7.1.3/src/backend/port/Makefile.in Mon Dec 11 02:49:54 2000 +++ pgsql713my/src/backend/port/Makefile.in Wed Dec 12 14:41:02 2001 @@ -27,6 +27,9 @@ ifeq ($(PORTNAME), qnx4) OBJS += getrusage.o qnx4/SUBSYS.o endif +ifeq ($(PORTNAME), nto-qnx) +OBJS += nto-qnx/SUBSYS.o +endif ifeq ($(PORTNAME), beos) OBJS += beos/SUBSYS.o endif @@ -44,6 +47,11 @@ qnx4.dir: $(MAKE) -C qnx4 all +nto-qnx/SUBSYS.o: nto-qnx.dir + +nto-qnx.dir: + $(MAKE) -C nto-qnx all + beos/SUBSYS.o: beos.dir beos.dir: @@ -62,6 +70,7 @@ $(MAKE) -C beos clean $(MAKE) -C darwin clean $(MAKE) -C qnx4 clean + $(MAKE) -C nto-qnx clean depend dep: $(CC) -MM $(CFLAGS) *.c >depend diff -P -r -u -b -d postgresql-7.1.3/src/backend/port/dynloader/nto-qnx.c pgsql713my/src/backend/port/dynloader/nto-qnx.c --- postgresql-7.1.3/src/backend/port/dynloader/nto-qnx.c Thu Jan 1 02:00:00 1970 +++ pgsql713my/src/backend/port/dynloader/nto-qnx.c Sat Nov 24 22:27:14 2001 @@ -0,0 +1,4 @@ +/* Dummy file used for nothing at this point + * + * see nto-qnx.h + */ diff -P -r -u -b -d postgresql-7.1.3/src/backend/port/dynloader/nto-qnx.h pgsql713my/src/backend/port/dynloader/nto-qnx.h --- postgresql-7.1.3/src/backend/port/dynloader/nto-qnx.h Thu Jan 1 02:00:00 1970 +++ pgsql713my/src/backend/port/dynloader/nto-qnx.h Sat Nov 24 22:25:30 2001 @@ -0,0 +1,23 @@ +/*------------------------------------------------------------------------- + */ +#ifndef PORT_PROTOS_H +#define PORT_PROTOS_H + +#include +#include "utils/dynamic_loader.h" + +/* dynloader.c */ +/* + * Dynamic Loader on QNX 6.1 + * + * this dynamic loader uses the system dynamic loading interface for shared + * libraries (ie. dlopen/dlsym/dlclose). The user must specify a shared + * library as the file to be dynamically loaded. + * + */ +#define pg_dlopen(f) dlopen(f,RTLD_NOW) +#define pg_dlsym dlsym +#define pg_dlclose dlclose +#define pg_dlerror dlerror + +#endif /* PORT_PROTOS_H */ diff -P -r -u -b -d postgresql-7.1.3/src/backend/port/nto-qnx/Makefile pgsql713my/src/backend/port/nto-qnx/Makefile --- postgresql-7.1.3/src/backend/port/nto-qnx/Makefile Thu Jan 1 02:00:00 1970 +++ pgsql713my/src/backend/port/nto-qnx/Makefile Sun Nov 25 11:46:36 2001 @@ -0,0 +1,36 @@ +#------------------------------------------------------------------------- +# +# Makefile-- +# Makefile for port/sparc +# +# IDENTIFICATION +# $Header: /home/projects/pgsql/cvsroot/pgsql/src/backend/port/qnx4/Makefile,v 1.3 2000/08/31 16:10:19 petere Exp $ +# +#------------------------------------------------------------------------- + +subdir = src/backend/port/nto-qnx +top_builddir = ../../../.. +include $(top_builddir)/src/Makefile.global + +OBJS = sem.o shm.o + +all: SUBSYS.o tstsem tstshm + +SUBSYS.o: $(OBJS) + $(LD) $(LDREL) $(LDOUT) SUBSYS.o $(OBJS) + +tstsem: tstsem.o sem.o + $(CC) -o tstsem sem.o tstsem.o + +tstshm: tstshm.o shm.o + $(CC) -o tstshm shm.o tstshm.o + +depend dep: + $(CC) -MM $(CFLAGS) *.c >depend + +clean: + rm -f SUBSYS.o $(OBJS) tstsem tstsem.o tstshm tstshm.o + +ifeq (depend,$(wildcard depend)) +include depend +endif diff -P -r -u -b -d postgresql-7.1.3/src/backend/port/nto-qnx/sem.c pgsql713my/src/backend/port/nto-qnx/sem.c --- postgresql-7.1.3/src/backend/port/nto-qnx/sem.c Thu Jan 1 02:00:00 1970 +++ pgsql713my/src/backend/port/nto-qnx/sem.c Sun Nov 25 11:38:40 2001 @@ -0,0 +1,349 @@ +/*------------------------------------------------------------------------- + * + * sem.c + * System V Semaphore Emulation + * + * Copyright (c) 1999, repas AEG Automation GmbH + * + * + * IDENTIFICATION + * $Header: /home/projects/pgsql/cvsroot/pgsql/src/backend/port/qnx4/sem.c,v 1.4 2001/02/02 18:21:58 momjian Exp $ + * + *------------------------------------------------------------------------- + */ + +#include +#include +#include +#include +#include +#include +#include +#include "postgres.h" +#include "storage/ipc.h" +#include "storage/proc.h" +#include "sem.h" + + +#define SETMAX ((MAXBACKENDS + PROC_NSEMS_PER_SET - 1) / PROC_NSEMS_PER_SET) +#define SEMMAX (PROC_NSEMS_PER_SET+1) +#define OPMAX 8 + +#define MODE 0700 +#define SHM_INFO_NAME "SysV_Sem_Info" + + +struct pending_ops +{ + int op[OPMAX]; /* array of pending operations */ + int idx; /* index of first free array member */ +}; + +struct sem_info +{ + sem_t sem; + struct + { + key_t key; + int nsems; + sem_t sem[SEMMAX];/* array of POSIX semaphores */ + struct sem semV[SEMMAX]; /* array of System V semaphore + * structures */ + struct pending_ops pendingOps[SEMMAX]; /* array of pending + * operations */ + } set[SETMAX]; +}; + +static struct sem_info *SemInfo = (struct sem_info *) - 1; + + +int +semctl(int semid, int semnum, int cmd, /* ... */ union semun arg) +{ + int r = 0; + + sem_wait(&SemInfo->sem); + + if (semid < 0 || semid >= SETMAX || + semnum < 0 || semnum >= SemInfo->set[semid].nsems) + { + sem_post(&SemInfo->sem); + errno = EINVAL; + return -1; + } + + switch (cmd) + { + case GETNCNT: + r = SemInfo->set[semid].semV[semnum].semncnt; + break; + + case GETPID: + r = SemInfo->set[semid].semV[semnum].sempid; + break; + + case GETVAL: + r = SemInfo->set[semid].semV[semnum].semval; + break; + + case GETALL: + for (semnum = 0; semnum < SemInfo->set[semid].nsems; semnum++) + arg.array[semnum] = SemInfo->set[semid].semV[semnum].semval; + break; + + case SETVAL: + SemInfo->set[semid].semV[semnum].semval = arg.val; + break; + + case SETALL: + for (semnum = 0; semnum < SemInfo->set[semid].nsems; semnum++) + SemInfo->set[semid].semV[semnum].semval = arg.array[semnum]; + break; + + case GETZCNT: + r = SemInfo->set[semid].semV[semnum].semzcnt; + break; + + case IPC_RMID: + for (semnum = 0; semnum < SemInfo->set[semid].nsems; semnum++) + { + if (sem_destroy(&SemInfo->set[semid].sem[semnum]) == -1) + r = -1; + } + SemInfo->set[semid].key = -1; + SemInfo->set[semid].nsems = 0; + break; + + default: + sem_post(&SemInfo->sem); + errno = EINVAL; + return -1; + } + + sem_post(&SemInfo->sem); + + return r; +} + +int +semget(key_t key, int nsems, int semflg) +{ + int fd, + semid, + semnum /* , semnum1 */ ; + int exist = 0; + + if (nsems < 0 || nsems > SEMMAX) + { + errno = EINVAL; + return -1; + } + + /* open and map shared memory */ + if (SemInfo == (struct sem_info *) - 1) + { + /* test if the shared memory already exists */ + fd = shm_open(SHM_INFO_NAME, O_RDWR | O_CREAT | O_EXCL, MODE); + if (fd == -1 && errno == EEXIST) + { + exist = 1; + fd = shm_open(SHM_INFO_NAME, O_RDWR | O_CREAT, MODE); + } + if (fd == -1) + return fd; + /* The size may only be set once. Ignore errors. */ + ftruncate( fd, sizeof(struct sem_info)); + SemInfo = mmap(NULL, sizeof(struct sem_info), + PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); + if (SemInfo == MAP_FAILED) + return -1; + if (!exist) + { + /* create semaphore for locking */ + sem_init(&SemInfo->sem, 1, 1); + sem_wait(&SemInfo->sem); + /* initilize shared memory */ + memset(SemInfo->set, 0, sizeof(SemInfo->set)); + for (semid = 0; semid < SETMAX; semid++) + SemInfo->set[semid].key = -1; + sem_post(&SemInfo->sem); + } + } + + sem_wait(&SemInfo->sem); + + if (key != IPC_PRIVATE) + { + /* search existing element */ + semid = 0; + while (semid < SETMAX && SemInfo->set[semid].key != key) + semid++; + if (!(semflg & IPC_CREAT) && semid >= SETMAX) + { + sem_post(&SemInfo->sem); + errno = ENOENT; + return -1; + } + else if (semid < SETMAX) + { + if (semflg & IPC_CREAT && semflg & IPC_EXCL) + { + sem_post(&SemInfo->sem); + errno = EEXIST; + return -1; + } + else + { + if (nsems != 0 && SemInfo->set[semid].nsems < nsems) + { + sem_post(&SemInfo->sem); + errno = EINVAL; + return -1; + } + sem_post(&SemInfo->sem); + return semid; + } + } + } + + /* search first free element */ + semid = 0; + while (semid < SETMAX && SemInfo->set[semid].key != -1) + semid++; + if (semid >= SETMAX) + { + sem_post(&SemInfo->sem); + errno = ENOSPC; + return -1; + } + + for (semnum = 0; semnum < nsems; semnum++) + { + sem_init(&SemInfo->set[semid].sem[semnum], 1, 0); +/* Currently sem_init always returns -1. + if( sem_init( &SemInfo->set[semid].sem[semnum], 1, 0 ) == -1 ) { + for( semnum1 = 0; semnum1 < semnum; semnum1++ ) { + sem_destroy( &SemInfo->set[semid].sem[semnum1] ); + } + sem_post( &SemInfo->sem ); + return -1; + } +*/ + } + + SemInfo->set[semid].key = key; + SemInfo->set[semid].nsems = nsems; + + sem_post(&SemInfo->sem); + + return semid; +} + +int +semop(int semid, struct sembuf * sops, size_t nsops) +{ + int i, + r = 0, + r1, + errno1 = 0, + op; + + sem_wait(&SemInfo->sem); + + if (semid < 0 || semid >= SETMAX) + { + sem_post(&SemInfo->sem); + errno = EINVAL; + return -1; + } + for (i = 0; i < nsops; i++) + { + if ( /* sops[i].sem_num < 0 || */ sops[i].sem_num >= SemInfo->set[semid].nsems) + { + sem_post(&SemInfo->sem); + errno = EFBIG; + return -1; + } + } + + for (i = 0; i < nsops; i++) + { + if (sops[i].sem_op < 0) + { + if (SemInfo->set[semid].semV[sops[i].sem_num].semval < -sops[i].sem_op) + { + if (sops[i].sem_flg & IPC_NOWAIT) + { + sem_post(&SemInfo->sem); + errno = EAGAIN; + return -1; + } + SemInfo->set[semid].semV[sops[i].sem_num].semncnt++; + if (SemInfo->set[semid].pendingOps[sops[i].sem_num].idx >= OPMAX) + { + /* pending operations array overflow */ + sem_post(&SemInfo->sem); + errno = ERANGE; + return -1; + } + SemInfo->set[semid].pendingOps[sops[i].sem_num].op[SemInfo->set[semid].pendingOps[sops[i].sem_num].idx++] = sops[i].sem_op; + /* suspend */ + sem_post(&SemInfo->sem); /* avoid deadlock */ + r1 = sem_wait(&SemInfo->set[semid].sem[sops[i].sem_num]); + sem_wait(&SemInfo->sem); + if (r1) + { + errno1 = errno; + r = r1; + /* remove pending operation */ + SemInfo->set[semid].pendingOps[sops[i].sem_num].op[--SemInfo->set[semid].pendingOps[sops[i].sem_num].idx] = 0; + } + else + SemInfo->set[semid].semV[sops[i].sem_num].semval -= -sops[i].sem_op; + SemInfo->set[semid].semV[sops[i].sem_num].semncnt--; + } + else + SemInfo->set[semid].semV[sops[i].sem_num].semval -= -sops[i].sem_op; + } + else if (sops[i].sem_op > 0) + { + SemInfo->set[semid].semV[sops[i].sem_num].semval += sops[i].sem_op; + op = sops[i].sem_op; + while (op > 0 && SemInfo->set[semid].pendingOps[sops[i].sem_num].idx > 0) + { /* operations pending */ + if (SemInfo->set[semid].pendingOps[sops[i].sem_num].op[SemInfo->set[semid].pendingOps[sops[i].sem_num].idx - 1] + op >= 0) + { + /* unsuspend processes */ + if (sem_post(&SemInfo->set[semid].sem[sops[i].sem_num])) + { + errno1 = errno; + r = -1; + } + /* adjust pending operations */ + op += SemInfo->set[semid].pendingOps[sops[i].sem_num].op[--SemInfo->set[semid].pendingOps[sops[i].sem_num].idx]; + SemInfo->set[semid].pendingOps[sops[i].sem_num].op[SemInfo->set[semid].pendingOps[sops[i].sem_num].idx] = 0; + } + else + { + /* adjust pending operations */ + SemInfo->set[semid].pendingOps[sops[i].sem_num].op[SemInfo->set[semid].pendingOps[sops[i].sem_num].idx - 1] += op; + op = 0; + } + } + } + else + /* sops[i].sem_op == 0 */ + { + /* not supported */ + sem_post(&SemInfo->sem); + errno = ENOSYS; + return -1; + } + SemInfo->set[semid].semV[sops[i].sem_num].sempid = getpid(); + } + + sem_post(&SemInfo->sem); + + errno = errno1; + return r; +} diff -P -r -u -b -d postgresql-7.1.3/src/backend/port/nto-qnx/sem.h pgsql713my/src/backend/port/nto-qnx/sem.h --- postgresql-7.1.3/src/backend/port/nto-qnx/sem.h Thu Jan 1 02:00:00 1970 +++ pgsql713my/src/backend/port/nto-qnx/sem.h Thu Apr 13 02:15:30 2000 @@ -0,0 +1,69 @@ +/*------------------------------------------------------------------------- + * + * sem.h + * System V Semaphore Emulation + * + * Copyright (c) 1999, repas AEG Automation GmbH + * + * + * IDENTIFICATION + * $Header: /home/projects/pgsql/cvsroot/pgsql/src/backend/port/qnx4/sem.h,v 1.3 2000/04/12 17:15:30 momjian Exp $ + * + *------------------------------------------------------------------------- + */ + +#ifndef _SYS_SEM_H +#define _SYS_SEM_H + +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + +/* + * Semctl Command Definitions. + */ + +#define GETNCNT 3 /* get semncnt */ +#define GETPID 4 /* get sempid */ +#define GETVAL 5 /* get semval */ +#define GETALL 6 /* get all semval's */ +#define GETZCNT 7 /* get semzcnt */ +#define SETVAL 8 /* set semval */ +#define SETALL 9 /* set all semval's */ + +/* + * There is one semaphore structure for each semaphore in the system. + */ + + struct sem + { + ushort_t semval; /* semaphore text map address */ + pid_t sempid; /* pid of last operation */ + ushort_t semncnt; /* # awaiting semval > cval */ + ushort_t semzcnt; /* # awaiting semval = 0 */ + }; + +/* + * User semaphore template for semop system calls. + */ + + struct sembuf + { + ushort_t sem_num; /* semaphore # */ + short sem_op; /* semaphore operation */ + short sem_flg; /* operation flags */ + }; + + extern int semctl(int semid, int semnum, int cmd, /* ... */ union semun arg); + extern int semget(key_t key, int nsems, int semflg); + extern int semop(int semid, struct sembuf * sops, size_t nsops); + +#ifdef __cplusplus +} + +#endif + +#endif /* _SYS_SEM_H */ diff -P -r -u -b -d postgresql-7.1.3/src/backend/port/nto-qnx/shm.c pgsql713my/src/backend/port/nto-qnx/shm.c --- postgresql-7.1.3/src/backend/port/nto-qnx/shm.c Thu Jan 1 02:00:00 1970 +++ pgsql713my/src/backend/port/nto-qnx/shm.c Sun Nov 25 11:40:16 2001 @@ -0,0 +1,231 @@ +/*------------------------------------------------------------------------- + * + * shm.c + * System V Shared Memory Emulation + * + * Copyright (cnf) 1999, repas AEG Automation GmbH + * + * + * IDENTIFICATION + * $Header: /home/projects/pgsql/cvsroot/pgsql/src/backend/port/qnx4/shm.c,v 1.4 2001/03/22 03:59:43 momjian Exp $ + * + *------------------------------------------------------------------------- + */ + +#include +#include +#include +#include +#include +#include +#include "shm.h" + + +#define MODE 0777 + +#define SHMMAX 1024 + + +struct shm_info +{ + int shmid; + key_t key; + size_t size; + caddr_t addr; +}; + +static struct shm_info *ShmInfo; + + +static int shm_putinfo(struct shm_info * info); +static int shm_updinfo(int i, struct shm_info * info); +static int shm_getinfo(int shmid, struct shm_info * info); +static int shm_getinfobyaddr(const void *addr, struct shm_info * info); + + +static int +shm_putinfo(struct shm_info * info) +{ + int i; + + if (ShmInfo == NULL) + { + ShmInfo = calloc(SHMMAX, sizeof(struct shm_info)); + if (ShmInfo == NULL) + return -1; + /* initialize ShmInfo */ + for (i = 0; i < SHMMAX; i++) + ShmInfo[i].shmid = -1; + } + + /* search first free element */ + i = 0; + while (i < SHMMAX && ShmInfo[i].shmid != -1) + i++; + if (i >= SHMMAX) + { + errno = ENOSPC; + return -1; + } + + memcpy(&ShmInfo[i], info, sizeof(struct shm_info)); + + return i; +} + +static int +shm_updinfo(int i, struct shm_info * info) +{ + if (i >= SHMMAX) + return -1; + if (ShmInfo == NULL) + return -1; + + memcpy(&ShmInfo[i], info, sizeof(struct shm_info)); + + return i; +} + +static int +shm_getinfo(int shmid, struct shm_info * info) +{ + int i; + + if (ShmInfo == NULL) + return -1; + + /* search element */ + i = 0; + while (i < SHMMAX && ShmInfo[i].shmid != shmid) + i++; + if (i >= SHMMAX) + return -1; + + memcpy(info, &ShmInfo[i], sizeof(struct shm_info)); + + return i; +} + +static int +shm_getinfobyaddr(const void *addr, struct shm_info * info) +{ + int i; + + if (ShmInfo == (struct shm_info *) - 1) + return -1; + + /* search element */ + i = 0; + while (i < SHMMAX && ShmInfo[i].addr != addr) + i++; + if (i >= SHMMAX) + return -1; + + memcpy(info, &ShmInfo[i], sizeof(struct shm_info)); + + return i; +} + + +void * +shmat(int shmid, const void *shmaddr, int shmflg) +{ + struct shm_info info; + int i; + + i = shm_getinfo(shmid, &info); + if (i == -1) + { + errno = EACCES; + return (void *) -1; + } + + info.addr = mmap((void *) shmaddr, info.size, + PROT_READ | PROT_WRITE, MAP_SHARED , shmid, 0); + if (info.addr == MAP_FAILED) + return info.addr; + + if (shm_updinfo(i, &info) == -1) + { + errno = EACCES; + return (void *) -1; + } + return info.addr; +} + +int +shmdt(const void *addr) +{ + struct shm_info info; + + if (shm_getinfobyaddr(addr, &info) == -1) + { + errno = EACCES; + return -1; + } + + return munmap((void *) addr, info.size); +} + +int +shmctl(int shmid, int cmd, struct shmid_ds * buf) +{ + struct shm_info info; + char name[NAME_MAX + 1]; + + if (cmd == IPC_RMID) + { + if (shm_getinfo(shmid, &info) == -1) + { + errno = EACCES; + return -1; + } + return shm_unlink(itoa(info.key, name, 16)); + } + if (cmd == IPC_STAT) + { + + /* + * Can we support IPC_STAT? We only need shm_nattch ... For now, + * punt and assume the shm seg does not exist. + */ + errno = EINVAL; + return -1; + } + errno = EINVAL; + return -1; +} + +int +shmget(int key, size_t size, int flags) +{ + char name[NAME_MAX + 1]; + int oflag = 0; + struct shm_info info; + + if (flags & IPC_CREAT) + oflag |= O_CREAT; + if (flags & IPC_EXCL) + oflag |= O_EXCL; + if (flags & SHM_R) + { + if (flags & SHM_W) + oflag |= O_RDWR; + else + oflag |= O_RDONLY; + } + info.shmid = shm_open(itoa(key, name, 16), oflag, MODE); + /* store shared memory information */ + if (info.shmid != -1) + { + info.key = key; + info.size = size; + info.addr = NULL; + if (shm_putinfo(&info) == -1) + return -1; + } + + /* The size may only be set once. Ignore errors. */ + ftruncate( info.shmid, size); + return info.shmid; +} diff -P -r -u -b -d postgresql-7.1.3/src/backend/port/nto-qnx/shm.h pgsql713my/src/backend/port/nto-qnx/shm.h --- postgresql-7.1.3/src/backend/port/nto-qnx/shm.h Thu Jan 1 02:00:00 1970 +++ pgsql713my/src/backend/port/nto-qnx/shm.h Sun Nov 18 19:53:20 2001 @@ -0,0 +1,44 @@ +/*------------------------------------------------------------------------- + * + * shm.h + * System V Shared Memory Emulation + * + * Copyright (c) 1999, repas AEG Automation GmbH + * + * + * IDENTIFICATION + * $Header: /home/projects/pgsql/cvsroot/pgsql/src/backend/port/qnx4/shm.h,v 1.3 2001/03/18 18:32:02 tgl Exp $ + * + *------------------------------------------------------------------------- + */ + +#ifndef _SYS_SHM_H +#define _SYS_SHM_H + +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + +#define SHM_R 0400 /* read permission */ +#define SHM_W 0200 /* write permission */ + + struct shmid_ds + { + int dummy; + int shm_nattch; + }; + + extern void *shmat(int shmid, const void *shmaddr, int shmflg); + extern int shmdt(const void *addr); + extern int shmctl(int shmid, int cmd, struct shmid_ds * buf); + extern int shmget(int key, size_t size, int flags); + +#ifdef __cplusplus +} + +#endif + +#endif /* _SYS_SHM_H */ diff -P -r -u -b -d postgresql-7.1.3/src/backend/port/nto-qnx/tstsem.c pgsql713my/src/backend/port/nto-qnx/tstsem.c --- postgresql-7.1.3/src/backend/port/nto-qnx/tstsem.c Thu Jan 1 02:00:00 1970 +++ pgsql713my/src/backend/port/nto-qnx/tstsem.c Sat Nov 17 23:37:02 2001 @@ -0,0 +1,202 @@ +/*------------------------------------------------------------------------- + * + * tstsem.c + * Test of System V Semaphore Emulation + * + * Copyright (c) 1999, repas AEG Automation GmbH + * + * + * IDENTIFICATION + * $Header: /home/projects/pgsql/cvsroot/pgsql/src/backend/port/qnx4/tstsem.c,v 1.3 2000/04/12 17:15:30 momjian Exp $ + * + *------------------------------------------------------------------------- + */ + + +#include +#include +#include +#include +#include "postgres.h" +#include "storage/ipc.h" +#include +#include "sem.h" + + +#define SEMMAX 16 +#define OPSMAX 1 + +static int semid; + +static void +sig_handler(int sig_no) +{ + union semun arg; + int i = semctl(semid, 0, GETNCNT, arg); + + if (i == -1) + perror("semctl"); + else + printf("semval = %d\n", i); +} + +int +main(int argc, char **argv) +{ + int c, + errflg = 0; + char s[80]; + key_t key = IPC_PRIVATE; + int nsems = SEMMAX; + int semflg = 0; + int unlink = 0; + int i; + struct sembuf sops[OPSMAX]; + u_short array[SEMMAX]; + union semun arg; + + optarg = NULL; + while (!errflg && (c = getopt(argc, argv, "k:n:cxu")) != -1) + { + switch (c) + { + case 'k': + key = atoi(optarg); + break; + case 'n': + nsems = atoi(optarg); + break; + case 'c': + semflg |= IPC_CREAT; + break; + case 'x': + semflg |= IPC_EXCL; + break; + case 'u': + unlink = 1; + break; + default: + errflg++; + } + } + if (errflg) + { + printf("usage: tstsem [-k key] [-n nsems] [-cxu]\n"); + exit(1); + } + + if (unlink) + { + i = shm_unlink("SysV_Sem_Info"); + if (i == -1) + perror("shm_unlink"); + exit(i); + } + + semid = semget(key, nsems, semflg); + if (semid == -1) + { + perror("semget"); + exit(semid); + } + + /* test signal interrupts */ + signal(SIGTERM, sig_handler); + + do + { + printf("(-)sem_op, (+)sem_op, (G)ETVAL, (S)ETVAL, GET(P)ID, GET(A)LL, SETA(L)L, GET(N)CNT, GET(Z)CNT, e(x)it: "); + scanf("%s", s); + switch (s[0]) + { + case '-': + case '+': + sops[0].sem_num = 0; + sops[0].sem_op = atoi(s); + if (sops[0].sem_op == 0) + sops[0].sem_op = s[0] == '+' ? +1 : -1; + sops[0].sem_flg = 0; + if (semop(semid, sops, 1) == -1) + perror("semop"); + break; + + case 'G': + case 'g': + i = semctl(semid, 0, GETVAL, arg); + if (i == -1) + perror("semctl"); + else + printf("semval = %d\n", i); + break; + + case 'S': + case 's': + printf("semval = "); + scanf("%d", &arg.val); + if (semctl(semid, 0, SETVAL, arg) == -1) + perror("semctl"); + break; + + case 'P': + case 'p': + i = semctl(semid, 0, GETPID, arg); + if (i == -1) + perror("semctl"); + else + printf("PID = %d\n", i); + break; + + case 'A': + case 'a': + arg.array = array; + i = semctl(semid, 0, GETALL, arg); + if (i == -1) + perror("semctl"); + else + { + for (i = 0; i < nsems; i++) + printf("semval[%d] = %hu\n", i, arg.array[i]); + } + break; + + case 'L': + case 'l': + arg.array = array; + for (i = 0; i < nsems; i++) + { + printf("semval[%d] = ", i); + scanf("%hu", &arg.array[i]); + } + if (semctl(semid, 0, SETALL, arg) == -1) + perror("semctl"); + break; + + case 'N': + case 'n': + i = semctl(semid, 0, GETNCNT, arg); + if (i == -1) + perror("semctl"); + else + printf("semval = %d\n", i); + break; + + case 'Z': + case 'z': + i = semctl(semid, 0, GETZCNT, arg); + if (i == -1) + perror("semctl"); + else + printf("semval = %d\n", i); + break; + } + } + while (s[0] != 'x'); + + if (semctl(semid, 0, IPC_RMID, arg) == -1) + { + perror("semctl"); + exit(-1); + } + + exit(0); +} diff -P -r -u -b -d postgresql-7.1.3/src/backend/port/nto-qnx/tstshm.c pgsql713my/src/backend/port/nto-qnx/tstshm.c --- postgresql-7.1.3/src/backend/port/nto-qnx/tstshm.c Thu Jan 1 02:00:00 1970 +++ pgsql713my/src/backend/port/nto-qnx/tstshm.c Sun Nov 18 20:18:00 2001 @@ -0,0 +1,105 @@ +/*------------------------------------------------------------------------- + * + * tstshm.c + * Test of System V Shared Memory Emulation + * + * Copyright (c) 1999, repas AEG Automation GmbH + * + * + * IDENTIFICATION + * $Header: /home/projects/pgsql/cvsroot/pgsql/src/backend/port/qnx4/tstshm.c,v 1.2 2000/04/12 17:15:30 momjian Exp $ + * + *------------------------------------------------------------------------- + */ + +#include +#include +#include +#include "shm.h" + + +int +main(int argc, char **argv) +{ + int c, + errflg = 0; + char s[80]; + key_t key = 0x1000; + size_t size = 256; + int shmid = -1; + caddr_t addr = NULL; + +// unsigned *addr = NULL; + + optarg = NULL; + while (!errflg && (c = getopt(argc, argv, "k:s:")) != -1) + { + switch (c) + { + case 'k': + key = atoi(optarg); + break; + case 's': + size = atoi(optarg); + break; + default: + errflg++; + } + } + if (errflg) + { + printf("usage: tstshm [-k key] [-s size]\n"); + exit(1); + } + + do + { + printf("shm(g)et, shm(a)t, shm(d)t, shm(c)tl, (w)rite, (r)ead, e(x)it: "); + scanf("%s", s); + switch (s[0]) + { + case 'g': + shmid = shmget(key, size, IPC_CREAT | SHM_R | SHM_W); + if (shmid == -1) + perror("shmget"); + printf("\n shmid %d",shmid); + break; + + case 'a': + addr = shmat(shmid, NULL, 0); + if (addr == (void *) -1) + perror("shmat"); + + printf( "Map addr is 0x%08x\n", addr ); + + break; + + case 'd': + if (shmdt(addr) == -1) + perror("shmdt"); + else + addr = NULL; + break; + + case 'c': + if (shmctl(shmid, IPC_RMID, NULL) == -1) + perror("shmctl"); + else + shmid = -1; + break; + + case 'w': + printf("\n\nString to write is 12345678 to 0x%08x\n",addr); +// strcpy((char *)addr,"12345678"); + scanf("%s", addr); + break; + + case 'r': + puts(addr); + break; + } + } + while (s[0] != 'x'); + + return 0; +} diff -P -r -u -b -d postgresql-7.1.3/src/backend/postmaster/postmaster.c pgsql713my/src/backend/postmaster/postmaster.c --- postgresql-7.1.3/src/backend/postmaster/postmaster.c Thu Apr 19 22:09:23 2001 +++ pgsql713my/src/backend/postmaster/postmaster.c Sun Dec 9 19:48:58 2001 @@ -726,6 +726,7 @@ } #endif i = open(NULL_DEV, O_RDWR | PG_BINARY); + dup2(i, 0); dup2(i, 1); dup2(i, 2); diff -P -r -u -b -d postgresql-7.1.3/src/backend/storage/file/fd.c pgsql713my/src/backend/storage/file/fd.c --- postgresql-7.1.3/src/backend/storage/file/fd.c Tue Apr 3 07:07:02 2001 +++ pgsql713my/src/backend/storage/file/fd.c Wed Dec 12 14:35:29 2001 @@ -47,6 +47,9 @@ #include #include #include +#if defined(__QNXNTO__) + #include // Andy Latin +#endif #include "miscadmin.h" #include "storage/fd.h" diff -P -r -u -b -d postgresql-7.1.3/src/backend/storage/ipc/ipc.c pgsql713my/src/backend/storage/ipc/ipc.c --- postgresql-7.1.3/src/backend/storage/ipc/ipc.c Fri Mar 23 06:49:54 2001 +++ pgsql713my/src/backend/storage/ipc/ipc.c Wed Dec 12 14:36:08 2001 @@ -46,6 +46,10 @@ #include #endif +#if defined(__QNXNTO__) // Andy Latin +#include "../../port/nto-qnx/shm.h" +#endif + #if defined(solaris_sparc) #include #endif diff -P -r -u -b -d postgresql-7.1.3/src/backend/utils/fmgr/fmgr.c pgsql713my/src/backend/utils/fmgr/fmgr.c --- postgresql-7.1.3/src/backend/utils/fmgr/fmgr.c Thu Mar 22 05:59:59 2001 +++ pgsql713my/src/backend/utils/fmgr/fmgr.c Mon Dec 10 21:04:53 2001 @@ -12,7 +12,6 @@ * *------------------------------------------------------------------------- */ - #include "postgres.h" #include "access/tuptoaster.h" diff -P -r -u -b -d postgresql-7.1.3/src/backend/utils/misc/guc.c pgsql713my/src/backend/utils/misc/guc.c --- postgresql-7.1.3/src/backend/utils/misc/guc.c Thu Mar 22 19:41:47 2001 +++ pgsql713my/src/backend/utils/misc/guc.c Wed Dec 12 14:37:26 2001 @@ -303,7 +303,9 @@ {NULL, 0, NULL, 0, 0, 0} }; - +#if defined(__QNXNTO__) // Andy Latin +#define DBL_MAX 1.79769313486231500e+308 +#endif static struct config_real ConfigureNamesReal[] = { diff -P -r -u -b -d postgresql-7.1.3/src/include/config.h.in pgsql713my/src/include/config.h.in --- postgresql-7.1.3/src/include/config.h.in Sun Apr 15 01:55:02 2001 +++ pgsql713my/src/include/config.h.in Wed Dec 12 14:37:59 2001 @@ -228,7 +228,7 @@ /* * Define this if your operating system supports AF_UNIX family sockets. */ -#if !defined(__QNX__) && !defined(__BEOS__) +#if !defined(__QNX__) && !defined(__BEOS__) && !defined(__QNXNTO__) // Andy Latin # define HAVE_UNIX_SOCKETS 1 #endif diff -P -r -u -b -d postgresql-7.1.3/src/include/port/nto-qnx.h pgsql713my/src/include/port/nto-qnx.h --- postgresql-7.1.3/src/include/port/nto-qnx.h Thu Jan 1 02:00:00 1970 +++ pgsql713my/src/include/port/nto-qnx.h Thu Nov 29 00:31:47 2001 @@ -0,0 +1,4 @@ +/* Dummy for QNX 6.1 */ + +#define HAVE_POSIX_SIGNALS + diff -P -r -u -b -d postgresql-7.1.3/src/interfaces/libpq/pqsignal.c pgsql713my/src/interfaces/libpq/pqsignal.c --- postgresql-7.1.3/src/interfaces/libpq/pqsignal.c Wed Jan 24 21:43:31 2001 +++ pgsql713my/src/interfaces/libpq/pqsignal.c Wed Dec 12 14:39:14 2001 @@ -35,7 +35,10 @@ sigemptyset(&act.sa_mask); act.sa_flags = 0; if (signo != SIGALRM) + ; +#if !defined(__QNXNTO__) // Andy Latin act.sa_flags |= SA_RESTART; +#endif if (sigaction(signo, &act, &oact) < 0) return SIG_ERR; return oact.sa_handler; diff -P -r -u -b -d postgresql-7.1.3/src/makefiles/Makefile.nto-qnx pgsql713my/src/makefiles/Makefile.nto-qnx --- postgresql-7.1.3/src/makefiles/Makefile.nto-qnx Thu Jan 1 02:00:00 1970 +++ pgsql713my/src/makefiles/Makefile.nto-qnx Sat Nov 24 23:31:42 2001 @@ -0,0 +1,10 @@ +AROPT = crs +export_dynamic = -Wl,-E +rpath = -Wl,-rpath,$(libdir) +shlib_symbolic = -Wl,-Bsymbolic + +DLSUFFIX = .so +CFLAGS_SL = -fpic + +%.so: %.o + $(CC) -shared -o $@ $< diff -P -r -u -b -d postgresql-7.1.3/src/pl/plpgsql/test/runtest pgsql713my/src/pl/plpgsql/test/runtest --- postgresql-7.1.3/src/pl/plpgsql/test/runtest Mon Oct 23 01:25:11 2000 +++ pgsql713my/src/pl/plpgsql/test/runtest Mon Dec 10 21:43:50 2001 @@ -3,17 +3,17 @@ DB=plpgsql_test export DB -FRONTEND="psql -e -q -X" +FRONTEND="psql -h localhost -e -q -X" export FRONTEND echo "*** destroy old $DB database ***" -dropdb $DB +#dropdb -h localhost $DB echo "*** create new $DB database ***" -createdb $DB +#createdb -h localhost $DB echo "*** install PL/pgSQL ***" -createlang plpgsql $DB +createlang -h localhost plpgsql $DB echo "*** create tables ***" $FRONTEND -f tables.sql -d $DB >output/tables.out 2>&1 diff -P -r -u -b -d postgresql-7.1.3/src/template/nto-qnx pgsql713my/src/template/nto-qnx --- postgresql-7.1.3/src/template/nto-qnx Thu Jan 1 02:00:00 1970 +++ pgsql713my/src/template/nto-qnx Sat Nov 24 22:48:59 2001 @@ -0,0 +1 @@ +CFLAGS='-O2 -Wl,-E' Only in postgresql-7.1.3/src/test/bench: create.sh diff -P -r -u -b -d postgresql-7.1.3/src/test/bench/create.sql pgsql713my/src/test/bench/create.sql --- postgresql-7.1.3/src/test/bench/create.sql Thu Jan 1 02:00:00 1970 +++ pgsql713my/src/test/bench/create.sql Sun Dec 9 17:36:17 2001 @@ -0,0 +1,17 @@ +create table onek(unique1 int4,unique2 int4,two int4,four int4,ten int4,twenty int4, hundred int4,thousand int4,twothousand int4,fivethous int4,tenthous int4,odd int4, even int4,stringu1 name,stringu2 name,string4 name); +create table tenk1 (unique1 int4,unique2 int4, two int4,four int4,ten int4,twenty int4,hundred int4,thousand int4,twothousand int4,fivethous int4,tenthous int4,odd int4,even int4,stringu1 name,stringu2 name,string4 name); +create table tenk2 (unique1 int4, unique2 int4, two int4, four int4,ten int4, twenty int4, hundred int4, thousand int4, twothousand int4,fivethous int4, tenthous int4, odd int4, even int4,stringu1 name,stringu2 name, string4 name); +copy onek from '/work1/pgsql713/src/test/bench/../regress/data/onek.data'; +copy tenk1 from '/work1/pgsql713/src/test/bench/../regress/data/tenk.data'; +copy tenk2 from '/work1/pgsql713/src/test/bench/../regress/data/tenk.data'; +create index onek_unique1 on onek using btree(unique1 int4_ops); +create index onek_unique2 on onek using btree(unique2 int4_ops); +create index onek_hundred on onek using btree(hundred int4_ops); +create index tenk1_unique1 on tenk1 using btree(unique1 int4_ops); +create index tenk1_unique2 on tenk1 using btree(unique2 int4_ops); +create index tenk1_hundred on tenk1 using btree(hundred int4_ops); +create index tenk2_unique1 on tenk2 using btree(unique1 int4_ops); +create index tenk2_unique2 on tenk2 using btree(unique2 int4_ops); +create index tenk2_hundred on tenk2 using btree(hundred int4_ops); +select * into table Bprime from tenk1 t where t.unique2 < 1000; +vacuum; diff -P -r -u -b -d postgresql-7.1.3/src/test/examples/testlibpq.c pgsql713my/src/test/examples/testlibpq.c --- postgresql-7.1.3/src/test/examples/testlibpq.c Tue Apr 25 19:39:07 2000 +++ pgsql713my/src/test/examples/testlibpq.c Sat Dec 8 18:10:42 2001 @@ -40,7 +40,7 @@ * defaults by looking up environment variables or, failing that, * using hardwired constants */ - pghost = NULL; /* host name of the backend server */ + pghost = "localhost"; /* host name of the backend server */ pgport = NULL; /* port of the backend server */ pgoptions = NULL; /* special options to start up the backend * server */ diff -P -r -u -b -d postgresql-7.1.3/src/test/performance/runtests.pl pgsql713my/src/test/performance/runtests.pl --- postgresql-7.1.3/src/test/performance/runtests.pl Fri Sep 26 17:55:20 1997 +++ pgsql713my/src/test/performance/runtests.pl Sun Nov 25 13:29:44 2001 @@ -11,7 +11,7 @@ # DBMS_name => [FrontEnd, DestroyDB command, CreateDB command] %DBMS = ( -'pgsql' => ["psql -q -d $DBNAME", "destroydb $DBNAME", "createdb $DBNAME"] +'pgsql' => ["psql -h localhost -q -d $DBNAME", "destroydb -h localhost $DBNAME", "createdb -h localhost $DBNAME"] ); # Tests to run: test' script, test' description, ...